import sq3 from 'sqlite3'

var dbPath = 'data.sqlite3'

const sqlite3 = sq3.verbose()
const db = new sqlite3.Database(dbPath)
db.serialize(() => {
  console.log('db.run')
  db.run(`CREATE TABLE IF NOT EXISTS activity (
    id          INTEGER  PRIMARY KEY AUTOINCREMENT,
    showid      STRING,
    acttype     STRING,
    content     STRING,
    actimg      STRING,
    actdate     DATE,
    visitorcount STRING,
    address     STRING
    )`, err => {
    console.log(err)
  })

  db.run(`CREATE TABLE IF NOT EXISTS changguan (
    id   INTEGER PRIMARY KEY AUTOINCREMENT,
    bianhao          STRING,
    changguanname    STRING,
    lianxiren        STRING,
    lianxidianhua    STRING,
    address          STRING,
    changguanjianjie STRING,
    changdijieshao   STRING,
    keyuyueshijian   DATE,
    pailianting      STRING,
    jiaotongzhiyin   STRING,
    visitorcount     STRING,
    pingjia          STRING,
    changguanimg     STRING
    )`, err => {
    console.log(err)
  })

  db.run(`CREATE TABLE IF NOT EXISTS zhiyuanfuwu (
    id      INTEGER PRIMARY KEY AUTOINCREMENT,
    name     STRING,
    sex      STRING,
    age      STRING,
    job      STRING,
    address  STRING,
    jifen    STRING,
    fuwujilu STRING
    )`, err => {
    console.log(err)
  })
})

export default db
